//
//  SetModeApi.m
//  MicrowaveLight
//
//  Created by Kendama on 2018/3/8.
//  Copyright © 2018年 DT. All rights reserved.
//

#import "SetModeApi.h"

@implementation SetModeApi
{
    NSDictionary *_dic;
}

-(id)initWithDic:(NSDictionary *)dic{
    if (self = [super init]) {
        _dic = dic;
    }
    return self;
}

- (NSString *)requestUrl {
    return @"/wblight/device/set_mode";
}

- (YTKRequestMethod)requestMethod {
    return YTKRequestMethodPOST;
}

- (id)requestArgument {
    NSMutableDictionary *dic = [NSMutableDictionary getPubdic];
    
    [dic setValuesForKeysWithDictionary:_dic];
    NSString *sign=[NSString getSign:dic];
    [dic setObject:sign forKey:@"sign"];
    return dic;
}


-(void)dealloc
{
    NSLog(@"%@ dealloc",[self class]);
}


+ (void)setMode:(int)mode success:(void (^)(NSDictionary *dic))successBack fail:(void (^)(NSDictionary *dic))failBack
{
    NSMutableDictionary *requestDic = [[NSMutableDictionary alloc]init];
    [requestDic setValue:@(mode).stringValue forKey:@"mode"];
    
    SetModeApi *api = [[SetModeApi alloc] initWithDic:requestDic];
    [api startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
        if (successBack)
        {
            successBack(request.responseObject);
        }
    } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
        if (failBack)
        {
            failBack(request.responseObject);
        }
    }];
    
}

@end
